package com.heima.admin.controller.v1;

import com.heima.admin.service.LoginService;
import com.heima.model.admin.dtos.AdLoginDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "用户登录管理", tags = "user", description = "登录管理API")
@RestController
@RequestMapping("login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 登录
     *
     * @param dto
     * @return
     */
    @ApiOperation("用户登录")
    @PostMapping("in")
    public ResponseResult login(@RequestBody AdLoginDto dto) {
        return loginService.login(dto);
    }

    /**
     * 注册
     *
     * @param adUser
     * @return
     */
    @ApiOperation("用户注册")
    @PostMapping("register")
    public ResponseResult register(@RequestBody AdUser adUser) {
        return loginService.register(adUser);
    }
}
